<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<%@ taglib prefix="order" tagdir="/WEB-INF/tags/order"%>
<div class="order_show" id="payPanel">
	<input type="hidden" id="salesOrderId" name="salesOrderId"	value="${order.salesOrderId}" />
	
	<table border="0" cellspacing="0" cellpadding="0" width="100%">
		<tr>
			<td style="vertical-align: top; width: 40%">
				<table border="0" cellspacing="0" cellpadding="0"
					class="consignee_table" width="100%">
					<tr>
						<th>
							<fmt:message key="salesOrder.orderNo" />
						</th>
						<td>
							${order.orderNo}
						</td>
					</tr>
					<tr>
						<th>
							<fmt:message key="salesOrder.totalAmount" />
						</th>
						<td>
							<common:currencyFormat value="${order.totalAmount}" />
						</td>
					</tr>
					<tr>
						<th>
							<fmt:message key="salesOrder.unPaidAmount"/>
						</th>
						<td>
							<span class="red">
								<common:currencyFormat value="${order.unPaidAmount}"/>
							</span>
						</td>
					</tr>
					<c:if test="${not empty order.paymentTypeDesc}">
						<tr>
							<th>
								<fmt:message key="salesOrder.paymentTypeDesc"/>
							</th>
							<td>
								${order.paymentTypeDesc}
							</td>
						</tr>
					</c:if>
					<tr>
						<th>
							<fmt:message key="salesOrder.hasInvoice"/>
						</th>
						<td>
							<fmt:message key="salesOrder.hasInvoice.${order.hasInvoice}"/>
						</td>
					</tr>
					<c:if test="${not empty order.invoiceTitle}">
						<tr>
							<th>
								<fmt:message key="salesOrder.invoiceTitle"/>
							</th>
							<td>
								${order.invoiceTitle}
							</td>
						</tr>
					</c:if>
					<tr>
						<th>
							<fmt:message key="orderPayment.payer"/>
						</th>
						<td>
							<input type="text" id="payer" name="payer"	value="${order.customerFirstname}" style="width:150px" class="inputtxt" />
						</td>
					</tr>
				</table>
			</td>
			<td style="vertical-align: top;">
				<table border="0" cellspacing="0" cellpadding="0"
					class="consignee_table" width="100%">
					<tr>
						<th>
							<fmt:message key="salesOrder.payPanel.paymentAmount" />(<span class="red">*</span>)
						</th>
						<td>
							<input type="text" id="paymentAmount" name="paymentAmount"	value="${order.unPaidAmount}" style="width:150px" class="inputtxt" />
						</td>
					</tr>
					<tr>
						<th>
							<fmt:message key="orderPayment.payee"/>
						</th>
						<td>
							<input type="text" id="payee" name="payee"	value="" style="width:150px" class="inputtxt" />
						</td>
					</tr>
					<tr>
						<th>
							<fmt:message key="orderPayment.paymentTypeDesc"/>(<span class="red">*</span>)
						</th>
						<td>
							<div>
								<input type="radio" value="-1" name="paymentMethodId" id="paymentMethodId" <c:if test="${order.paymentMethodId==1 or order.paymentMethodId==5}">checked</c:if>>
								<fmt:message key="orderPayment.paymentType.offline"/>&nbsp;&nbsp;
								<select name="paymentType">
									<option value="1" <c:if test="${order.paymentType==1}">selected</c:if> ><fmt:message key="orderPayment.paymentType.offline.cash"/></option>
									<option value="2" <c:if test="${order.paymentType==2}">selected</c:if> ><fmt:message key="orderPayment.paymentType.offline.pos"/></option>
									<option value="3" <c:if test="${order.paymentType==3}">selected</c:if> ><fmt:message key="orderPayment.paymentType.offline.paper"/></option>
								</select>
							</div>
							<hr/>
							<div>
								<input type="radio" value="2" name="paymentMethodId" <c:if test="${order.paymentMethodId==2}">checked</c:if>>
								<fmt:message key="orderPayment.paymentType.online"/>&nbsp;&nbsp;
								<select name="paymentGatewayName">
									<c:forEach items="${onlinePaymentMethodList}" var="paymentMethod">
										<option value="${paymentMethod.paymentGateway.paymentGatewayName}">${paymentMethod.paymentGateway.paymentGatewayName}</option>
									</c:forEach>
								</select>
							</div>
							<hr/>
							<div>
								<input type="radio" value="3" name="paymentMethodId" <c:if test="${order.paymentMethodId==3}">checked</c:if>>
								<fmt:message key="orderPayment.paymentType.bankTransfer"/>
								<c:set var="accountInfo">
									<fmt:message key="orderPayment.paymentType.bankTransfer.address"/>:${appConfig.bankAccountAddress}&#13;&#10;<fmt:message key="orderPayment.paymentType.bankTransfer.accountName"/>:${appConfig.bankAccountName}&#13;&#10;<fmt:message key="orderPayment.paymentType.bankTransfer.accountNo"/>:${appConfig.bankAccountNo}
								</c:set>
								<textarea id="accountInfoBankTransfer" name="accountInfoBankTransfer" value="" style="height:70px;width:260px" class="textareatxt" >${fn:trim(accountInfo)}</textarea>
							</div>
							<hr/>
							<div>
								<input type="radio" value="4" name="paymentMethodId" <c:if test="${order.paymentMethodId==4}">checked</c:if>>
								<fmt:message key="orderPayment.paymentType.postoffice"/>&nbsp;&nbsp;
								<c:set var="accountInfo">
									<fmt:message key="orderPayment.paymentType.postoffice.account"/>:${appConfig.postofficeAccountNo}&#13;&#10;<fmt:message key="orderPayment.paymentType.postoffice.receiver"/>:${appConfig.postofficePayee}
								</c:set>
								<textarea id="accountInfoPostOffice" name="accountInfoPostOffice" value="" style="height:70px;width:260px" class="textareatxt" >${fn:trim(accountInfo)}</textarea>
							</div>
						</td>
					</tr>
					<tr>
						<th>
							<fmt:message key="orderPayment.memo"/>
						</th>
						<td>
							<textarea id="memo" name="memo" style="height:150px;width:320px" class="textareatxt" ></textarea>
						</td>
					</tr>
				</table>	
			</td>
		</tr>
	</table>
</div>
<v:javascript formName="orderPay" staticJavascript="false" />
<script type="text/javascript">
$j(document).ready(function () {
	applyValidate($('accountInfoBankTransfer'),"maxlength=512");
	applyValidate($('accountInfoPostOffice'),"maxlength=512");
	applyValidate($('paymentAmount'),"required,price,minValue=0.01,maxValue=${order.unPaidAmount}");
});	

</script>
